<?php
/**
 * This file contains the class FDSubmitModel which provides
 * most of the code requirements for the FDSubmit page
 *
 * @copyright  2009 A Memory Tree
 * @license    A Memory Tree License
 * @version    $Id:$
 * @link       http://my-trac.assembla.com/amemorytree/ticket/??
 * @since      File available since Release 0.1
 */
/**
 * This class provides the code for FDSubmit
 *
 * @copyright  2009 A Memory Tree
 * @license    A Memory Tree License
 * @version    Release: @package_version@
 * @link       http://my-trac.assembla.com/amemorytree/ticket/??
 * @since      Class available since Release 0.1
 */
class FDSubmitModel
{
    /**
     * A mailer implementation
     *
     * @var EmailModel
     */
    private $_email;
    /**
     * Create a new instance of this class
     */
    public function __construct($email)
    {
        $this->_email = $email;
    }
    /**
     * Return an associated array to store person info
     *
     * @return array[string]mixed
     * @param mixed $surname
     * @param mixed $firstNames
     * @param mixed $prevName
     * @param mixed $neeName
     * @param mixed $akaName
     * @param mixed $deathDay
     * @param mixed $deathMonth
     * @param mixed $deathYear
     * @param mixed $birthDay
     * @param mixed $birthMonth
     * @param mixed $birthYear
     * @param mixed $age
     * @param mixed $ageMeasure
     * @param mixed $cityTown
     * @param mixed $formerCityTown
     * @param mixed $regionId
     * @param mixed $countryId
     * @param mixed $charityId
     * @param mixed $funeralHomeId
     * @param mixed $otherInfo
     * @param mixed $addedOn
     * @param mixed $photo
     */
    function createPersonInfo($surname, $firstNames, $prevName, $neeName, $akaName,
            $deathDay, $deathMonth, $deathYear, $birthDay, $birthMonth, $birthYear,
            $age, $ageMeasure, $cityTown, $formerCityTown, $regionId, $countryId,
            $charityId, $funeralHomeId, $otherInfo, $addedOn, $photo)
    {
        $deathDate = "$deathDay $deathMonth $deathYear";
        $deathDateTime = strftime("%Y-%m-%d %X", strtotime($deathDate));
        $birthDate = "$birthDay $birthMonth $birthYear";
        $birthDateTime = strftime("%Y-%m-%d %X", strtotime($birthDate));
        return array(
            'surname' => $surname
          , 'firstNames' => $firstNames
          , 'prevName' => $prevName
          , 'neeName' => $neeName
          , 'akaName' => $akaName
          , 'deathDate' => $deathDateTime
          , 'birthDate' => $birthDateTime
          , 'age' => $age
          , 'ageMeasure' => $ageMeasure
          , 'cityTownId' => $cityTown
          , 'formerCityTownId' => $formerCityTown
          , 'regionId' => $regionId
          , 'countryId' => $countryId
          , 'charityId' => $charityId
          , 'funeralHomeId' => $funeralHomeId
          , 'otherInfo' => $otherInfo
          , 'addedOn' => $addedOn
          , 'photo' => $photo
        );    
    }
    /**
     * Send an email
     * 
     * @return void
     * @param string $fromName
     * @param string $fromEmail
     * @param string $toEmail
     * @param string $subject
     * @param string $message
     */
    function sendEmail($fromName, $fromEmail, $toEmail, $subject, $message)
    {
        $email = $this->_email;
        $email->setFromName($fromName);
        $email->setFromEmail($fromEmail);
        $email->setToEmail($toEmail);
        $email->setSubject($subject);
        $email->setMessage($message);
        $email->send();
    }
    /**
     * Send an email about the successfully created Remembrance page
     * 
     * @return void
     * @param string $toEmail
     * @param string $subject
     * @param string $message
     */
    function theteamEmail($subject, $message)
    {
        $fromName = 'Web Server';
        $fromEmail = 'server@amemorytree.co.nz';
        $toEmail = 'theteam@amemorytree.co.nz';
        $this->sendEmail($fromName, $fromEmail, $toEmail, $subject, $message);
    }
    /**
     * Send an email about the successfully created Remembrance page
     * 
     * @return void
     * @param string $toEmail
     * @param string $subject
     * @param string $message
     */
    function remembranceSuccessEmail($toEmail, $subject, $message)
    {
        $fromName = 'A Memory Tree';
        $fromEmail = 'theteam@amemorytree.co.nz';
        $this->sendEmail($fromName, $fromEmail, $toEmail, $subject, $message);
    }
}
